c高手,"fflush(stdout)"是什么意思,没有遇到过啊(在线)

来源:百度知道 编辑:UC知道 时间:2024/06/30 05:48:12
有一道c语言题:
#include<stdio.h>
char *name[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
void main(void)
{
int d,m,y,e,t,f;
printf("请输入日:");
fflush(stdout);
scanf("%d",&d);
printf("请输入月:");
fflush(stdout);
scanf("%d",&m);
printf("请输入年:");
fflush(stdout);
scanf("%d",&y);
switch(m)
{
case 1:e=d;break;
case 2:e=31+d;break;
case 3:e=59+d;break;
case 4:e=90+d;break;
case 5:e=120+d;break;
case 6:e=151+d;break;
case 7:e=181+d;break;
case 8:e=212+d;break;
case 9:e=243+d;break;
case 10:e=273+d;break;
case 11:e=304+d;break;
case 12:e=334+d;break;
default:return;
}
if(y%4==0&&y%100!=0||y%400==0)
if(m>2)
++e;
--y;
t=y+y/4-y/100+y/400+e;
f=t%7;
prin

刷新输出缓冲区
其实这里不需要,因为遇到输入时会自动刷新缓冲区,使缓冲区内容置空

清空输出缓冲区,并把缓冲区内容输出

函数名: fflush
功 能: 清除一个流
用 法: int fflush(FILE *stream);
程序例:

#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <io.h>

void flush(FILE *stream);

int main(void)
{
FILE *stream;
char msg[] = "This is a test";

/* create a file */
stream = fopen("DUMMY.FIL", "w");

/* write some data to the file */
fwrite(msg, strlen(msg), 1, stream);

clrscr();
printf("Press any key to flush\
DUMMY.FIL:");
getch();

/* flush the data to DUMMY.FIL without\
closing it */
flush(stream);

printf("\nFile was flushed, Press any key\
to quit:");
getch();
return 0;
}

void flush(FILE *stream)
{
int duph